/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package org.teacake.filteringproxy;

/**
 *
 * @author tkleisas
 */
public class URLProcessor {
    public static String extractHostname(String URL)
    {
        int startindex = URL.indexOf("//");
        int endindex = URL.indexOf("/", startindex+2);
        String hostname = URL.substring(startindex+2,endindex);
        return hostname;

    }
    public static int extractPort(String URL)
    {
        String hostname = extractHostname(URL);
        int startindex = hostname.indexOf(":");
        if(startindex<0)
        {
            return 80;
        }


        String port = hostname.substring(startindex+1);
        try
        {
           return Integer.parseInt(port);
        }
        catch(Exception e)
        {
            
        }
        return 80;

    }
    public static void main(String [] args)
    {

    }
}
